package com.houweishi.module.realReport.controller;

import com.houweishi.common.annotation.Log;
import com.houweishi.common.core.controller.BaseController;
import com.houweishi.common.core.domain.AjaxResult;
import com.houweishi.common.core.page.TableDataInfo;
import com.houweishi.common.enums.BusinessType;
import com.houweishi.common.utils.poi.ExcelUtil;
import com.houweishi.module.realReport.domain.RealReport;
import com.houweishi.module.realReport.service.IRealReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 实时汇报Controller
 * 
 * @author yqq
 * @date 2023-06-28
 */
@RestController
@RequestMapping("/module/realReport")
public class RealReportController extends BaseController
{
    @Autowired
    private IRealReportService realReportService;

    /**
     * 查询实时汇报列表
     */
    @PreAuthorize("@ss.hasPermi('module:realReport:list')")
    @GetMapping("/list")
    public TableDataInfo list(RealReport realReport)
    {
        startPage();
        List<RealReport> list = realReportService.selectRealReportList(realReport);
        return getDataTable(list);
    }

    /**
     * 导出实时汇报列表
     */
    @PreAuthorize("@ss.hasPermi('module:realReport:export')")
    @Log(title = "实时汇报", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RealReport realReport)
    {
        List<RealReport> list = realReportService.selectRealReportList(realReport);
        ExcelUtil<RealReport> util = new ExcelUtil<RealReport>(RealReport.class);
        util.exportExcel(response, list, "实时汇报数据");
    }

    /**
     * 获取实时汇报详细信息
     */
    @PreAuthorize("@ss.hasPermi('module:realReport:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(realReportService.selectRealReportById(id));
    }

    /**
     * 新增实时汇报
     */
    @PreAuthorize("@ss.hasPermi('module:realReport:add')")
    @Log(title = "实时汇报", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RealReport realReport)
    {
        return toAjax(realReportService.insertRealReport(realReport));
    }

    /**
     * 修改实时汇报
     */
    @PreAuthorize("@ss.hasPermi('module:realReport:edit')")
    @Log(title = "实时汇报", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RealReport realReport)
    {
        return toAjax(realReportService.updateRealReport(realReport));
    }

    /**
     * 删除实时汇报
     */
    @PreAuthorize("@ss.hasPermi('module:realReport:remove')")
    @Log(title = "实时汇报", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(realReportService.deleteRealReportByIds(ids));
    }
}
